 /**
 * @file tkl_network_recovery.h
 * @brief Common process - network recovery
 * @version 1.0.0
 * @date 2021-05-01
 *
 * @copyright Copyright 2021-2022 Tuya Inc. All Rights Reserved.
 *
 */

#ifndef __TKL_NETWORK_RECOVERY_H__
#define __TKL_NETWORK_RECOVERY_H__


#ifdef __cplusplus
    extern "C" {
#endif

#include "tuya_cloud_types.h"
#include "tuya_zigbee_stack.h"

typedef enum {
    NWK_RECOVERY_SUCESS = 0,
    NWK_RECOVERY_FAILED
} TKL_RECOVERY_STATUS_E;

typedef struct {
    UINT16_T node_id;           ///< node short addr,if 0xffff random generation, otherwise user specified
    UINT8_T channel;            ///< target network channel(11~26)
    INT8_T tx_power;            ///< node tx power value
    ZG_NODE_TYPE_E node_type;   ///< node type
    ZG_NWK_TYPE_E nwk_type;     ///< target network type
    UINT16_T panid;             ///< target network panid
    UINT8_T *ext_panid;         ///< target network extend panid
    UINT8_T *tc_mac;            ///< gateway or trust center mac address
    UINT8_T *nwk_key;           ///< network key
} TKL_OUTOF_BAND_JOIN_T;

/**
 * @brief zigbee network recovery init
 *
 * @param[in] none
 * @return  none
 */
VOID_T tkl_zg_nwk_recovery_init(VOID_T);

/**
 * @brief zigbee network recovery disable
 *
 * @param[in] en: TRUE disables the network recovery 
 * @note the default is enabled network recovery
 * @return  none
 */
VOID_T tkl_zg_nwk_recovery_disable(BOOL_T en);

/**
 * @brief zigbee network recovery start
 * it must be used in the no network state
 *
 * @param[in] none
 * @return  none
 */
VOID_T tkl_zg_nwk_recovery_start(VOID_T);

/**
 * @brief zigbee network recovery information save
 *
 * @param[in] none
 * @return  none
 */
BOOL_T tkl_zg_nwk_recovery_info_save(VOID_T);

/**
 * @brief zigbee network recovery information clear
 *
 * @param[in] none
 * @return  none
 */
BOOL_T tkl_zg_nwk_recovery_info_clear(VOID_T);

/**
 * @brief zigbee network recovery is available
 *
 * @param[in] none
 * @return  TRUE: available
 */
BOOL_T tkl_zg_nwk_recovery_is_available(VOID_T);

/**
 * @brief zigbee out of band network join
 *
 * @param[in] info: network necessary information
 * @return  TRUE: sucess
 */
BOOL_T tkl_zg_nwk_out_of_band_join(TKL_OUTOF_BAND_JOIN_T *info);

#ifdef __cplusplus
}
#endif

#endif
